<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <form action="http://www.baidu.com" method="post">
    姓名：<input type="text" value="" name="name" autofocus id="name" pattern="\d+">
   性别：<input type="radio" name="sex" value="nv" checked>女
    <input type="radio" name="sex" value="nan" >男
    兴趣：<input type="checkbox" name="xingqu"value="lanqiu">篮球
        <input type="checkbox" name="xingqu"value="lanqiu">足球
        <select name="minzu" id="">
            <option value="hanzu">汉族</option>
                        <option value="hanzu" selected>回族</option>

        </select>
<input type="submit" value="tijiao">

    </form>

</body>
<script>
    document.getElementById("name").oninput = function(e) {
        console.log(this.checkValidity())

        if(!this.checkValidity()){
            this.value = this.value.substring(0,this.value.length-1);
           e.preventDefault();
        }
    }
    function a(){
        var str=location.search.length?location.search.substring(1):[];
        var arg={};
        var items=str.length?str.split("&"):[];
       for(i=0;i<items.length;i++){
           var item=items[i].length?items[i].split("="):[];
           var name=decodeURIComponent(item[0]);
           var value=decodeURIComponent(item[1]);
           arg["name"]=value;


       } 
return arg;


    }

</script>
</html>